<!--考勤卡中心-换卡-->
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib prefix="my" uri="http://www.trkj.com/tr1702/tags" %>
<html>
<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript"
	src="<c:url value="/js/jquery-easyui-1.5.5.6/jquery.min.js"  />"></script>
<script type="text/javascript"
	src="<c:url value="/js/jquery-easyui-1.5.5.6/jquery.easyui.min.js"/>"></script>
<script type="text/javascript"
	src="<c:url value="/js/jquery-easyui-1.5.5.6/locale/easyui-lang-zh_CN.js"/>"></script>
<link rel="stylesheet" type="text/css"
	href="<c:url value="/js/jquery-easyui-1.5.5.6/themes/default/easyui.css"/>" />
<link rel="stylesheet" type="text/css"
	href="<c:url value="/js/jquery-easyui-1.5.5.6/themes/icon.css"/>">
<title>考勤卡中心-换卡</title>
</head>
<body>
	<script type="text/javascript">
	$(".is_timecard_exchange").click(function(){
		var href=$(this).attr("data-text");
		$("#timecard_center_exchange").panel({    
		    href:href,    
		    onLoad:function(){    
		        
		    }    
		}); 
	});
	var timecard_exchange = function(value,row,index){
		var timecar_no_only_exchange="";
		<my:g id="31">timecar_no_only_exchange = "<a style='' btn='timecard_exchange_btn_only' onclick=onlytimecar_no_exchange(" + row.TIMECARD_ID + ","+row.ATTCARD_ID+",'"+row.STAIN_NAME+"',"+row.STAIN_ID+")>换卡</a>";</my:g>
		return timecar_no_only_exchange;
	}
	//换卡
	var onlytimecar_no_exchange =function(timecarId,attcard_id,stainName,stain_id){
		
		$("#dd-timecard_center_stop").window("open");
		$("#emp_id_stop").textbox("setValue",stain_id);//员工id
		$("#emp_name_stop").textbox("setValue",stainName);//姓名
		$("#timecar_no_text_stop").textbox("setValue",timecarId);
		$("#emp_attr_stop").textbox("setValue",attcard_id);
	}
	$("#dgcard_with_center_exchange").datagrid({
		onLoadSuccess:function(){
			$("a[btn=timecard_exchange_btn_only]").linkbutton({iconCls:'icon-update_red', plain:true});
		}
	});
	//打开考勤卡dialog
	$("#timecard_add_no_new").linkbutton({
		onClick:function(){
			$("#inserttimecard_stop").dialog("open");
			$("#table_timecard_center_stop").datagrid("reload");
		}
	});
	//搜索新的考勤卡
	$("#timecard_see_stop").linkbutton({
		onClick:function(){
			var seeText = $("#timecard_see_text_stop").textbox("getText");
			$("#table_timecard_center_stop").datagrid({url:'find_timecard_id_no?timecardId='+seeText,method:'get'});
			$("#table_timecard_center_stop").datagrid("reload");
		}
	});
	//双击新的考勤卡
	$('#table_timecard_center_stop').datagrid({onDblClickRow:function(index,row){
		$('#timecar_no_text_stop_new').textbox('setValue',row.TIMECARD_ID);
		//关闭窗口
		$('#inserttimecard_stop').dialog('close');
	}
	});
	//刷新
	$("#exchange_reload").linkbutton({
		onClick:function(){
			$("#dgcard_with_center_exchange").datagrid("reload");
		}
	});
	</script>
	<div id="timecard_center_exchange" class="easyui-panel" data-options="fit:true,border:false">   
    
	
	<table id="dgcard_with_center_exchange"  class="easyui-datagrid"
	data-options="
				fitColumns:true,
				fit:true,
				url:'to_is_findTimecardandEmp',
				method:'get',
				pagination:true,     
				pageSize:10,    
				pageList: [10,20,30,40,50], 
				rownumbers:true,
				Striped:true, 
				singleSelect:true,
				striped:true,
				toolbar:'#tbcard_center_exchange'
        ">
		<thead>
			<tr>
				<th  align="center" data-options="field:'ATTCARD_ID'">考勤卡配卡编号</th>
				<th align="center" data-options="field:'TIMECARD_ID',width:65">考勤卡</th>
				<th align="center" data-options="field:'STAIN_ID',width:85">员工编号</th>
				<th align="center" data-options="field:'STAIN_NAME',width:85">员工名称</th>
				<th align="center" data-options="field:'ATTCARD_EFFECT',width:230,formatter:function(value,row,index){
					if(value!=null){
						var date = new Date(value);
						return date.toLocaleString();
					}
					return; 
				}">开始时间</th>
				<th align="center" data-options="field:'ATTCARD_LOSEEFF',width:230,formatter:function(value,row,index){
					if(value!=null){
						var date = new Date(value);
						return date.toLocaleString();
					}
					return; 
				}">结束时间</th>
				<th align="center" data-options="field:'ATTCARD_REASON',width:105">原因</th>
				<th align="center" data-options="field:'ATTCARD_REMARKS',width:105">备注</th>
				<th align="center" data-options="field:'ATTCARD_PERSON',width:75">创建者</th>
				<th align="center" data-options="field:'ATTCARD_STARTDATE',width:220,formatter:function(value,row,index){
					if(value!=null){
						var date = new Date(value);
						return date.toLocaleString();
					}
					return; 
				}">创建日期</th>
				<!-- <th align="center" data-options="field:'TIMECARD_UPDATE',width:130,formatter:function(value,row,index){
					if(value!=null){
						var date = new Date(value);
						return date.toLocaleString();
					}
					return; 
				}">更新日期</th> -->
				<!-- <th align="center" data-options="field:'TIMECARD_ZT',width:60,hidden:true"></th> -->
				<th align="center" data-options="field:'xxx',width:80,formatter:timecard_exchange"></th>
				<!-- <th align="center" data-options="field:'xxx1',width:270"></th> -->
			</tr>
		</thead>
	</table>
	<div id="tbcard_center_exchange">
		<!-- <a href="#" class="easyui-linkbutton"
			data-options="iconCls:'icon-add',disabled:true">新增</a> -->
			<span class="xtb-sep_center"></span>
		<a href="#" class="easyui-linkbutton"
			data-options="iconCls:'icon-reload'" id="exchange_reload">刷新</a>
			<span class="xtb-sep_center"></span>
			<a href="#"
			class="easyui-menubutton"
			data-options="menu:'#mm1_no_exchange',iconCls:'icon-edit'">凭证列表</a> <input
			class="easyui-textbox" data-options="prompt:'考勤卡'"
			style="width: 150px" id="timecard_center_no_text"> <a class="easyui-linkbutton"
			data-options="iconCls:'icon-search'" id="timecard_center_no">搜素</a>
	</div>

	<!-- 选择操作面板 -->
	<div id="mm1_no_exchange" style="width: 150px;">
		<div data-options="iconCls:'icon-undo'" class="is_timecard_exchange" data-text="to_time_card_center_nos">未分配的考勤卡</div>
		<div data-options="iconCls:'icon-redo'" class="is_timecard_exchange"data-text="to_is_timecard_center_exchange"style="color:red;">已分配的考勤卡</div>
		<div data-options="iconCls:'icon-redo'" class="is_timecard_exchange"data-text="to_is_timecard_center_stop" >已停用的考情卡</div>
	</div>
	
	
	
	<!-- 换勤卡 -->
	<div id="dd-timecard_center_stop" class="easyui-dialog" title="换卡"
		data-options="
         width:370,
         height:260,
	     resizable:false,
	     modal:true,
	   	closed:true,
	     buttons:[{
				text:'确定',
				width:60,
				handler:function(){
					$('#timecard_exchange').form({
						url:'is_exchange_timecard',
						method:'post',
						onSubmit:function(params){
								params['stainId']=$('#emp_id_stop').textbox('getText');
								params['timecardId']=$('#timecar_no_text_stop_new').textbox('getText');
								params['timecardId1']=$('#timecar_no_text_stop').textbox('getText');
								alert($('#timecar_no_text_stop').textbox('getText'))
								params['attcardId']=$('#emp_attr_stop').textbox('getText');
								
								params['exchageTime']=$('#timecard_no_time_new').datetimebox('getText');
								return $(this).form('validate');
						},
						success:function(v){
							v = eval('('+v +')');
							if(v.success){
								$.messager.alert('恭喜', '添加成功');
							}else{
								$.messager.alert('错误', '对不起，操作失败，原因：' + v.message);
							}
						$.messager.progress('close');// 如果提交成功则隐藏进度条
						$('#dgcard_with_center_exchange').datagrid('reload');
						$('#timecard_exchange').form('reset');
						$('#dd-timecard_center_stop').dialog('close');
						}
					}).submit();
				}
				},{
				text:'取消',
				width:60,	
				handler:function(){
					$('#dd-timecard_center_stop').dialog('close');
				}
			}]
        ">
		<div> 
			<form action="" id="timecard_exchange" style="text-align: right;">
				<table style="margin-left:5%;" cellpadding="2">
					<tr style="display:none;">
						<td><input class="easyui-textbox"
							data-options="readonly:true,width:100" id="emp_attr_stop"></td>
					</tr>
					<tr>
						<td><input class="easyui-textbox"
							data-options="readonly:true,label:'员工 '" id="emp_id_stop"></td>
						<td><a id="emp_add" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-add',disabled:true"></a></td>
						<td><input class="easyui-textbox"
							data-options="readonly:true,width:100" id="emp_name_stop"></td>
					</tr>
					<tr>
						<td><input class="easyui-textbox"
							data-options="readonly:true,label:'原考勤卡'" id="timecar_no_text_stop"></td>
						<td></td>
					</tr>
					
					<tr>
						<td><input class="easyui-textbox"
							data-options="required:true,label:'新考勤卡'" id="timecar_no_text_stop_new"></td>
						<td><a id="timecard_add_no_new" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-add'"></a></td>
					</tr>
				</table>
				<div style="float:left;margin-left:5%;" >
					<input class="easyui-datetimebox" data-options="required:true,label:'更换日期',panelHeight:270,width:260" id="timecard_no_time_new">
				</div>
			</form>
		</div>
	</div>
	
	<!-- 考勤卡 -->
	<!--考勤卡查找-->
		<div id="inserttimecard_stop" class="easyui-dialog"
		data-options="
		width:450,
		title:'清单查找-考勤卡',
		bodyCls:'awby',
		modal:true,
		closed:true,
		buttons:[{
				text:'添加',
				iconCls:'icon-ok',
				handler:function(){
					$('#timecard_center_no').form({
							onSubmit:function(){
								var rows=$('#table_timecard_center_stop').datagrid('getSelected');
								if(rows!=null){
									$('#timecar_no_text_stop_new').textbox('setValue',rows.TIMECARD_ID);
									$('#inserttimecard_stop').dialog('close');
								}else{
									$.messager.alert('提示','请选择考勤卡'); 
								}
								
							},
							success:function(v){
								
							}
						}).submit();
				}
			},{
				text:'关闭',
				iconCls:'icon-cancel',
				handler:function(){
					$('#inserttimecard_stop').dialog('close');
				}
			}]">
				<div>
					<form action="" >
						<table id="list_timecard_stop">
							<tr>
								<td><input class="easyui-textbox"
									data-options="label:'编号', width:200,labelWidth:60" id="timecard_see_text_stop"/></td>
									<td><a class="easyui-linkbutton" id="timecard_see_stop">查询</a></td>
							</tr>
						
							
						</table>
					</form>
				</div>
				<table class="easyui-datagrid" id="table_timecard_center_stop"
					data-options="   
				method:'post',
				pagination:true,     
				pageSize:5, 
				pagePosition:'bottom',   
				url:'is_to_all_timecards',  
				pageList: [5,10,15,20,25], 
				rownumbers:true,
				Striped:true, 
				singleSelect:true,
				striped:true
				">
					<thead>
						<tr>
							<th data-options="field:'TIMECARD_ID',width:200">考勤卡</th>
							
						</tr>
					</thead>
					<tbody>

					</tbody>
				</table>
			</div>
	</div> 
	
</body>
</html>